package com.zhang.learns.jpa.service.impl;

import com.zhang.learns.jpa.entity.Users;
import com.zhang.learns.jpa.repository.UserRepository;
import com.zhang.learns.jpa.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;

/**
 * @author zhanghaolian
 * @date 2021/12/27 14:18
 */
@Service
public class UserServiceImpl implements IUserService {
    @Autowired
    private UserRepository userPepository;

    @Transactional
    @Override
    public Users addUser(Users user) {
        userPepository.save(user);
        return user;
    }

    @Override
    public Iterable<Users> findAll() {
        userPepository.findAll();
        return userPepository.findAll();
    }
}
